1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gio.Notification; 26 27 private import gio.IconIF; 28 private import gio.c.functions; 29 public import gio.c.types; 30 private import glib.ConstructionException; 31 private import glib.Str; 32 private import glib.Variant; 33 private import gobject.ObjectG; 34 35 36 /** 37 * #GNotification is a mechanism for creating a notification to be shown 38 * to the user -- typically as a pop-up notification presented by the 39 * desktop environment shell. 40 * 41 * The key difference between #GNotification and other similar APIs is 42 * that, if supported by the desktop environment, notifications sent 43 * with #GNotification will persist after the application has exited, 44 * and even across system reboots. 45 * 46 * Since the user may click on a notification while the application is 47 * not running, applications using #GNotification should be able to be 48 * started as a D-Bus service, using #GApplication. 49 * 50 * In order for #GNotification to work, the application must have installed 51 * a `.desktop` file. For example: 52 * |[ 53 * [Desktop Entry] 54 * Name=Test Application 55 * Comment=Description of what Test Application does 56 * Exec=gnome-test-application 57 * Icon=org.gnome.TestApplication 58 * Terminal=false 59 * Type=Application 60 * Categories=GNOME;GTK;TestApplication Category; 61 * StartupNotify=true 62 * DBusActivatable=true 63 * X-GNOME-UsesNotifications=true 64 * ]| 65 * 66 * The `X-GNOME-UsesNotifications` key indicates to GNOME Control Center 67 * that this application uses notifications, so it can be listed in the 68 * Control Center’s ‘Notifications’ panel. 69 * 70 * The `.desktop` file must be named as `org.gnome.TestApplication.desktop`, 71 * where `org.gnome.TestApplication` is the ID passed to g_application_new(). 72 * 73 * User interaction with a notification (either the default action, or 74 * buttons) must be associated with actions on the application (ie: 75 * "app." actions). It is not possible to route user interaction 76 * through the notification itself, because the object will not exist if 77 * the application is autostarted as a result of a notification being 78 * clicked. 79 * 80 * A notification can be sent with g_application_send_notification(). 81 * 82 * Since: 2.40 83 */ 84 public class Notification : ObjectG 85 { 86 /** the main Gtk struct */ 87 protected GNotification* gNotification; 88 89 /** Get the main Gtk struct */ 90 public GNotification* getNotificationStruct(bool transferOwnership = false) 91 { 92 if (transferOwnership) 93 ownedRef = false; 94 return gNotification; 95 } 96 97 /** the main Gtk struct as a void* */ 98 protected override void* getStruct() 99 { 100 return cast(void*)gNotification; 101 } 102 103 /** 104 * Sets our main struct and passes it to the parent class. 105 */ 106 public this (GNotification* gNotification, bool ownedRef = false) 107 { 108 this.gNotification = gNotification; 109 super(cast(GObject*)gNotification, ownedRef); 110 } 111 112 113 /** */ 114 public static GType getType() 115 { 116 return g_notification_get_type(); 117 } 118 119 /** 120 * Creates a new #GNotification with @title as its title. 121 * 122 * After populating @notification with more details, it can be sent to 123 * the desktop shell with g_application_send_notification(). Changing 124 * any properties after this call will not have any effect until 125 * resending @notification. 126 * 127 * Params: 128 * title = the title of the notification 129 * 130 * Returns: a new #GNotification instance 131 * 132 * Since: 2.40 133 * 134 * Throws: ConstructionException GTK+ fails to create the object. 135 */ 136 public this(string title) 137 { 138 auto __p = g_notification_new(Str.toStringz(title)); 139 140 if(__p is null) 141 { 142 throw new ConstructionException("null returned by new"); 143 } 144 145 this(cast(GNotification*) __p, true); 146 } 147 148 /** 149 * Adds a button to @notification that activates the action in 150 * @detailed_action when clicked. That action must be an 151 * application-wide action (starting with "app."). If @detailed_action 152 * contains a target, the action will be activated with that target as 153 * its parameter. 154 * 155 * See g_action_parse_detailed_name() for a description of the format 156 * for @detailed_action. 157 * 158 * Params: 159 * label = label of the button 160 * detailedAction = a detailed action name 161 * 162 * Since: 2.40 163 */ 164 public void addButton(string label, string detailedAction) 165 { 166 g_notification_add_button(gNotification, Str.toStringz(label), Str.toStringz(detailedAction)); 167 } 168 169 /** 170 * Adds a button to @notification that activates @action when clicked. 171 * @action must be an application-wide action (it must start with "app."). 172 * 173 * If @target is non-%NULL, @action will be activated with @target as 174 * its parameter. 175 * 176 * Params: 177 * label = label of the button 178 * action = an action name 179 * target = a #GVariant to use as @action's parameter, or %NULL 180 * 181 * Since: 2.40 182 */ 183 public void addButtonWithTargetValue(string label, string action, Variant target) 184 { 185 g_notification_add_button_with_target_value(gNotification, Str.toStringz(label), Str.toStringz(action), (target is null) ? null : target.getVariantStruct()); 186 } 187 188 /** 189 * Sets the body of @notification to @body. 190 * 191 * Params: 192 * body_ = the new body for @notification, or %NULL 193 * 194 * Since: 2.40 195 */ 196 public void setBody(string body_) 197 { 198 g_notification_set_body(gNotification, Str.toStringz(body_)); 199 } 200 201 /** 202 * Sets the type of @notification to @category. Categories have a main 203 * type like `email`, `im` or `device` and can have a detail separated 204 * by a `.`, e.g. `im.received` or `email.arrived`. Setting the category 205 * helps the notification server to select proper feedback to the user. 206 * 207 * Standard categories are [listed in the specification](https://specifications.freedesktop.org/notification-spec/latest/ar01s06.html). 208 * 209 * Params: 210 * category = the category for @notification, or %NULL for no category 211 * 212 * Since: 2.70 213 */ 214 public void setCategory(string category) 215 { 216 g_notification_set_category(gNotification, Str.toStringz(category)); 217 } 218 219 /** 220 * Sets the default action of @notification to @detailed_action. This 221 * action is activated when the notification is clicked on. 222 * 223 * The action in @detailed_action must be an application-wide action (it 224 * must start with "app."). If @detailed_action contains a target, the 225 * given action will be activated with that target as its parameter. 226 * See g_action_parse_detailed_name() for a description of the format 227 * for @detailed_action. 228 * 229 * When no default action is set, the application that the notification 230 * was sent on is activated. 231 * 232 * Params: 233 * detailedAction = a detailed action name 234 * 235 * Since: 2.40 236 */ 237 public void setDefaultAction(string detailedAction) 238 { 239 g_notification_set_default_action(gNotification, Str.toStringz(detailedAction)); 240 } 241 242 /** 243 * Sets the default action of @notification to @action. This action is 244 * activated when the notification is clicked on. It must be an 245 * application-wide action (start with "app."). 246 * 247 * If @target is non-%NULL, @action will be activated with @target as 248 * its parameter. 249 * 250 * When no default action is set, the application that the notification 251 * was sent on is activated. 252 * 253 * Params: 254 * action = an action name 255 * target = a #GVariant to use as @action's parameter, or %NULL 256 * 257 * Since: 2.40 258 */ 259 public void setDefaultActionAndTargetValue(string action, Variant target) 260 { 261 g_notification_set_default_action_and_target_value(gNotification, Str.toStringz(action), (target is null) ? null : target.getVariantStruct()); 262 } 263 264 /** 265 * Sets the icon of @notification to @icon. 266 * 267 * Params: 268 * icon = the icon to be shown in @notification, as a #GIcon 269 * 270 * Since: 2.40 271 */ 272 public void setIcon(IconIF icon) 273 { 274 g_notification_set_icon(gNotification, (icon is null) ? null : icon.getIconStruct()); 275 } 276 277 /** 278 * Sets the priority of @notification to @priority. See 279 * #GNotificationPriority for possible values. 280 * 281 * Params: 282 * priority = a #GNotificationPriority 283 */ 284 public void setPriority(GNotificationPriority priority) 285 { 286 g_notification_set_priority(gNotification, priority); 287 } 288 289 /** 290 * Sets the title of @notification to @title. 291 * 292 * Params: 293 * title = the new title for @notification 294 * 295 * Since: 2.40 296 */ 297 public void setTitle(string title) 298 { 299 g_notification_set_title(gNotification, Str.toStringz(title)); 300 } 301 302 /** 303 * Deprecated in favor of g_notification_set_priority(). 304 * 305 * Deprecated: Since 2.42, this has been deprecated in favour of 306 * g_notification_set_priority(). 307 * 308 * Params: 309 * urgent = %TRUE if @notification is urgent 310 * 311 * Since: 2.40 312 */ 313 public void setUrgent(bool urgent) 314 { 315 g_notification_set_urgent(gNotification, urgent); 316 } 317 }